package com.rjyb.student_management_platform.dao;

import com.rjyb.student_management_platform.pojo.AnswerSheet;
import com.rjyb.student_management_platform.pojo.Jobtable;
import com.rjyb.student_management_platform.pojo.Student;
import com.rjyb.student_management_platform.pojo.Teacher;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public interface LoginDao {

    //1.学生登录
    @Select("select * from student where #{name} = student.studentId and #{password} = student.password")
    Student login1(String name, String password);

    //2.老师登录
    @Select("select * from teacher where #{name} = teacher.jobNumber and #{password} = teacher.password")
    Teacher login2(String name, String password);



    //3.已到次数
    @Select("select count(*) from attendance att where sid=#{sid} and att.atRate=1")
    int selectatt1(long sid);


    //4.未到次数
    @Select("select count(*) from attendance att where sid=#{sid} and att.atRate=2")
    int selectatt2(long sid);


    //5.迟到次数
    @Select("select count(*) from attendance att where sid=#{sid} and att.atRate=3")
    int selectatt3(long sid);


    //6.请假次数
    @Select("select count(*) from attendance att where sid=#{sid} and att.atRate=4")
    int selectatt4(long sid);


    //7.查询已完成作业
    @Select("select an.remedy,an.correct,an.answerTime,j.jobName from answer_sheet an,jobtable j where an.sid=#{sid} and an.jid=j.jid ORDER BY answerTime desc")
    List<Map> selectans(int sid);


    //8.查询未完成作业
    @Select("select * from jobtable j where not exists (select * from answer_sheet an where j.jid=an.jid and an.sid=#{sid})  and j.cid=#{cid} ORDER BY j.jobData desc")
    List<Jobtable> selectans1(int sid, int cid);


    //9.查询学生所在班级
    @Select("select cid from class_student cs where cs.sid=#{sid}")
    int selectclass(int sid);
}
